#ifndef COMMAND_H
#define COMMAND_H

#include "imageset.h"

typedef enum { 
	CMD_SET_PIXEL, CMD_RESIZE, CMD_MIRROR, CMD_ROTATE,
} CommandType;

typedef struct {
	uint16_t x, y;
	uint8_t color;
	uint8_t _old_color;
} CmdSetPixel;

typedef struct {
	Rect r;
	uint16_t _old_w, _old_h;
	uint8_t* _old_data;
} CmdResize;

typedef struct {
	Inversion inv;
} CmdMirror;

typedef struct {
	Rotation rot;
} CmdRotate;

typedef struct
{
	CommandType command;
	union {
		CmdSetPixel sp;
		CmdResize rs;
		CmdMirror mr;
		CmdRotate ro;
	};
} Command;

typedef struct {
	int (*cmd)(Image* img, Command* cmd);
	int (*cmd_undo)(Image* img, Command* cmd);
} CommandFunction;
extern CommandFunction command_functions[];

void command_free(Command* cmd);

#endif
